MySQL grammer

SQL基础

Select

1
2
3
select column1, column2, ...
from table_name;
select * from table_name;

Distinct

1
2
select distinct column1, column2, ...
from table_name;

Where

1
2
3
select column1, column2, ...
from table_name
where condition;

And , Or, Not

1
2
3
4
5
6
7
8
9
10
11
select column1, column2, ...
from table_name
where condition1 and condition2 and condition3 ...;
select column1, column2, ...
from table_name
where condition1 or condition2 or condition3 ...;
select column1, column2, ...
from table_name
where not condition;

Order By

1
2
3
select column1, column2, ...
from table_name
order by column1, column2, ... ASC|DESC;

Insert Into

1
2
3
4
5
insert into table_name
values (value1, value2, value3, ...);
insert into table_name (column1, column2, column3, ...)
values (value1, value2, value3, ...);

Null Values

1
2
3
4
5
6
7
select column_names
from table_name
where column_name is null;
select column_names
from table_name
where column_name is not null;

Update

1
2
3
update table_name
set column1 = value1, column2 = value2, ...
where condition;

Delete

1
2
delete from table_name
where condition;